<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Harmony Web</title>
    <script type="text/javascript">
      // 调用原生方法
      function hello() {
        harmonyObject.hello();
      }
      // 返回Promise测试
      async function singleCall() {
        let res = await harmonyObject.singleCall(["来自js代码"]);
        console.log(`js singleCall then-->${res}`);
      }
      // 传入回调测试
      function multiCall() {
        harmonyObject.multiCall(
          ["来自js代码"],
          res => {
            console.log(`js multiCall then-->${res}`);
          },
          error => {
            console.log(`js multiCall error-->${error}`);
          }
        );
      }

      // 提供方法给鸿蒙调用
      function nativeCall(str) {
        console.log(`js 鸿蒙调用-->${str}`);
      }
    </script>
  </head>
  <body>
    <p>鸿蒙测试页面</p>
    <button onclick="hello()">hello</button>
    <br />
    <button onclick="singleCall()">返回Promise</button>
    <br />
    <button onclick="multiCall()">传入回调</button>
    <br />
  </body>
</html>
